public class Solution_704 {
    public int search(int[] nums, int target) {
//            0  1   2   3
        //    11 22  33  44

        int left = 0;
        int right = nums.length - 1;


        while (left <= right){
            int mid = (left + right) / 2;
            if (nums[mid] == target){
                return mid;
            } else if (nums[mid] < target){
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }

        return -1;
    }
}
